const mysql = require("mysql2");
const pool = mysql.createPool({
  host: "192.168.1.115",
  port: 3306,
  database: "jiaju",
  user: "root",
  password: "rootroot",
});
const query = (sqlstr) => {
  return new Promise((reslove, reject) => {
    pool.getConnection((error, conn) => {
      if (error) {
        reject(error);
      } else {
        pool.query(sqlstr, (err, result) => {
          if (err) reject(err);
          else reslove(result);
        });
        conn.release();
      }
    });
  });
};
module.exports = query;
